﻿@model PH.Model.Accounts.UserModel

<div class="ph-tabs">
    <ul>
        <li class="k-state-active">帐号信息</li>
        @if (PH.Web.Global.WebContext.CurrentUser.Roles.Any(p => p.RoleName == "SchoolAdmin"))
        {
            <li>学校信息</li>
        }
        else if (PH.Web.Global.WebContext.CurrentUser.Roles.Any(p => p.RoleName == "Bureau"))
        {
            <li>机构信息</li>
        }
    </ul>
    <div>
        <div class="GeneralEdit" id="fmUser">
            <ul>
                <li>
                    <label for="txtUserName">用户名：</label>
                    <input type="text" class="k-textbox" id="txtUserName" name="user" value="@Model.UserName" required validationMessage="请输入用户名" />
                    <span class="k-invalid-msg" data-for="userName"></span>
                </li>
                <li>
                    <label for="txtRealName">姓名：</label>
                    <input type="text" class="k-textbox" id="txtRealName" name="realName" value="@Model.RealName" required validationMessage="请输入你的姓名" />
                    <span class="k-invalid-msg" data-for="realName"></span>
                </li>
                <li>
                    <label for="txtMobile">联系手机：</label>
                    <input type="tel" class="k-textbox" id="txtMobile" name="mobile" value="@Model.Mobile" />
                </li>
                <li>
                    <label for="txtEmail">Email：</label>
                    <input type="email" class="k-textbox" id="txtEmail" name="email" value="@Model.Email" />
                </li>
                <li class="editButtons" style="text-align:left; padding-left:300px">
                    <button id="btnSaveUser" class="k-button"><span class="k-icon k-i-tick"></span><span>确认提交</span></button>
                </li>
            </ul>
        </div>
    </div>
    <div>
        @if (PH.Web.Global.WebContext.CurrentUser.Roles.Any(p => p.RoleName == "SchoolAdmin"))
        {
            <div class="GeneralEdit">
                <ul>
                    <li>
                        <label for="txtUserName">学校编码：</label>
                        <span style="font-weight:bold">@ViewBag.School.Code</span>
                    </li>
                    <li>
                        <label for="txtRealName">学校名称：</label>
                        <span style="font-weight:bold">@ViewBag.School.SchoolName</span>
                    </li>
                </ul>
            </div>
        }
        else if (PH.Web.Global.WebContext.CurrentUser.Roles.Any(p => p.RoleName == "Bureau"))
        {
            <div class="GeneralEdit">
                <ul>
                    <li>
                        <label for="txtUserName">机构编码：</label>
                        <span style="font-weight:bold">@ViewBag.Bureau.Code</span>
                    </li>
                    <li>
                        <label for="txtRealName">机构名称：</label>
                        <span style="font-weight:bold">@ViewBag.Bureau.EduName</span>
                    </li>
                </ul>
            </div>
        }
    </div>
</div>

<script class="save_user">
    LocatedMenu("我的信息", "帐号管理");
    $(function () {
        var validator = $("#fmUser").kendoValidator().data("kendoValidator");
        $("#btnSaveUser").click(function (e) {
            if (validator.validate()) {
                var values = {
                    guid: "@Model.Guid",
                    userName: $("#txtUserName").val(),
                    realname: $("#txtRealName").val(),
                    mobile: $("#txtMobile").val(),
                    email: $("#txtEmail").val()
                };

                Whale.Remote.Operation({
                    url: "/Accounts/User/SaveUser",
                    parameters: values,
                    success: function (result) {
                        wndGeneralInformation.content("信息修改成功！").open();
                    },
                    error: function (msg) {
                        wndGeneralInformation.content(msg).open();
                    }
                });
            }
            return false;
        });
    });
</script>



